﻿using DFGK_WMS.IRepository;
using DFGK_WMS.Model.DTO;
using DFGK_WMS.Model.Models;
using DFGK_WMS.WebAPI.Controllers.Result;
using DFGK_WMS.WebAPI.Tools;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;

namespace DFGK_WMS.WebAPI.Controllers.数字孪生
{
    /// <summary>
    /// agv信息
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TAgvmesgController : ControllerBase
    {
        private readonly WebSocketConnectManager socketManager;

        public TAgvmesgController(WebSocketConnectManager socketConnectManager)
        {
            this.socketManager = socketConnectManager;
        }
        /// <summary>
        /// agv设备信息添加
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public IActionResult AgvmesgReturn(TAgvmsgDto msg)
        {
            socketManager.SendMsgToAllClients(JsonConvert.SerializeObject(new {type=5,data=msg}));
            return Ok(BaseResult.ReturnInfo(0, "", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
        }
        /// <summary>
        /// agv设备故障或者任务结束时上报
        /// </summary>
        /// <returns></returns>
        //[HttpPost]
        //public IActionResult AgvmesgAppear(AgvmesgDto dto)
        //{
        //    socketManager.SendMsgToAllClients(JsonConvert.SerializeObject(new {type=6,data=dto}));
        //    return Ok(BaseResult.ReturnInfo(0, "", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
        //}

    }
}
